package com.zrx.govern.component.easyexcel.starter.listener;

import com.zrx.govern.component.easyexcel.starter.config.ExcelConfigProperties;
import com.zrx.govern.component.easyexcel.starter.utils.JsonParseUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.refresh.ContextRefresher;
import org.springframework.cloud.endpoint.event.RefreshEvent;
import org.springframework.cloud.endpoint.event.RefreshEventListener;

import java.util.Set;

/**
 * @author zhangxiaowei
 * @desc
 */
@Slf4j
public class ExcelJsonRefreshEventListener extends RefreshEventListener {

    @Autowired
    private ExcelConfigProperties excelConfigProperties;

    public ExcelJsonRefreshEventListener(ContextRefresher refresh) {
        super(refresh);
    }

    @Override
    public void handle(RefreshEvent event) {
        super.handle(event);
        log.info("********json配置文件刷新了**********");
        JsonParseUtil.initExcelSettingJson(excelConfigProperties);
    }
}
